package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Courses4;
import com.ruoyi.system.service.ICourses4Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课程4Controller
 * 
 * @author ruoyi
 * @date 2025-02-14
 */
@RestController
@RequestMapping("/system/courses4")
public class Courses4Controller extends BaseController
{
    @Autowired
    private ICourses4Service courses4Service;

    /**
     * 查询课程4列表
     */
    @PreAuthorize("@ss.hasPermi('system:courses4:list')")
    @GetMapping("/list")
    public TableDataInfo list(Courses4 courses4)
    {
        startPage();
        List<Courses4> list = courses4Service.selectCourses4List(courses4);
        return getDataTable(list);
    }

    /**
     * 导出课程4列表
     */
    @PreAuthorize("@ss.hasPermi('system:courses4:export')")
    @Log(title = "课程4", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Courses4 courses4)
    {
        List<Courses4> list = courses4Service.selectCourses4List(courses4);
        ExcelUtil<Courses4> util = new ExcelUtil<Courses4>(Courses4.class);
        util.exportExcel(response, list, "课程4数据");
    }

    /**
     * 获取课程4详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:courses4:query')")
    @GetMapping(value = "/{courseId}")
    public AjaxResult getInfo(@PathVariable("courseId") Long courseId)
    {
        return success(courses4Service.selectCourses4ByCourseId(courseId));
    }

    /**
     * 新增课程4
     */
    @PreAuthorize("@ss.hasPermi('system:courses4:add')")
    @Log(title = "课程4", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Courses4 courses4)
    {
        return toAjax(courses4Service.insertCourses4(courses4));
    }

    /**
     * 修改课程4
     */
    @PreAuthorize("@ss.hasPermi('system:courses4:edit')")
    @Log(title = "课程4", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Courses4 courses4)
    {
        return toAjax(courses4Service.updateCourses4(courses4));
    }

    /**
     * 删除课程4
     */
    @PreAuthorize("@ss.hasPermi('system:courses4:remove')")
    @Log(title = "课程4", businessType = BusinessType.DELETE)
	@DeleteMapping("/{courseIds}")
    public AjaxResult remove(@PathVariable Long[] courseIds)
    {
        return toAjax(courses4Service.deleteCourses4ByCourseIds(courseIds));
    }
}
